﻿<Window x:Class="myManga.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
        xmlns:local="clr-namespace:myManga"
        xmlns:vm="clr-namespace:myManga.ViewModels"
        Title="myManga" 
        x:Name="ThisMainWindow"
        Height="460" 
        Width="680"
        
        Style="{StaticResource DarkWindow}"
        
        TextElement.FontFamily="Segoe UI"
        TextElement.Foreground="White" 
        Icon="/myManga;component/Resources/Icon.ico">
    <Window.CommandBindings>
        <CommandBinding Command="{x:Static shell:SystemCommands.CloseWindowCommand}"
                    Executed="_OnSystemCommandCloseWindow"/>
        <CommandBinding Command="{x:Static shell:SystemCommands.MaximizeWindowCommand}"
                    Executed="_OnSystemCommandMaximizeWindow"/>
        <CommandBinding Command="{x:Static shell:SystemCommands.MinimizeWindowCommand}"
                    Executed="_OnSystemCommandMinimizeWindow"/>
        <CommandBinding Command="{x:Static shell:SystemCommands.ShowSystemMenuCommand}"
                    Executed="_OnSystemCommandShowSystemMenu"/>
    </Window.CommandBindings>
    <Window.TaskbarItemInfo>
        <TaskbarItemInfo Description="myManga">
            <TaskbarItemInfo.ThumbButtonInfos>
                <ThumbButtonInfo 
                    Description="Update Info" 
                    DismissWhenClicked="True" 
                    ImageSource="/myManga;component/Resources/Images/Metro/White/No%20Circle/Cloud-refresh.png"
                    Command="{Binding UpdateLibraryManga}"/>
            </TaskbarItemInfo.ThumbButtonInfos>
        </TaskbarItemInfo>
    </Window.TaskbarItemInfo>
    <Window.DataContext>
        <vm:MainViewModel/>
    </Window.DataContext>
    <Window.Resources>
        <ResourceDictionary Source="/myManga;component/Resources/ViewModel-View-Link.xaml"/>
    </Window.Resources>
    
    <Grid Background="Black" TextBlock.Foreground="White" TextBlock.FontFamily="Segoe UI">
        <Grid.Triggers>
            <EventTrigger RoutedEvent="Grid.Loaded">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation 
                            Storyboard.TargetName="watermark"
                            Storyboard.TargetProperty="Opacity"
                            BeginTime="0:0:10" From="1" To="0"/>
                        <ObjectAnimationUsingKeyFrames 
                            Storyboard.TargetName="watermark"
                            Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0:0:12" Value="{x:Static Visibility.Hidden}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Grid.Triggers>
        
        <TabControl
            SelectedIndex="{Binding Path=ViewIndex, Mode=TwoWay}">
            <TabControl.Resources>
                <Thickness x:Key="TabItemMargin">0</Thickness>
            </TabControl.Resources>
            <TabItem Header="{DynamicResource ResourceKey=LibraryTabText}">
                <ContentControl Margin="{StaticResource ResourceKey=TabItemMargin}" Content="{Binding Path=LibraryViewModel}"/>
            </TabItem>
            <TabItem Header="{DynamicResource ResourceKey=ReaderTabText}" IsEnabled="{Binding Path=ReadingViewModel.IsEnabled}">
                <ContentControl Margin="{StaticResource ResourceKey=TabItemMargin}" Content="{Binding Path=ReadingViewModel}"/>
            </TabItem>
            <TabItem Header="{DynamicResource ResourceKey=QueueTabText}">
                <ContentControl Margin="{StaticResource ResourceKey=TabItemMargin}" Content="{Binding Path=QueueViewModel}"/>
            </TabItem>
            <TabItem Header="{DynamicResource ResourceKey=SearchTabText}">
                <ContentControl Margin="{StaticResource ResourceKey=TabItemMargin}" Content="{Binding Path=SearchViewModel}"/>
            </TabItem>
            <TabItem Header="{DynamicResource ResourceKey=OptionsTabText}">
                <TabControl TabStripPlacement="Left" Background="Black">
                    <TabItem Header="{DynamicResource ResourceKey=AboutTabText}">
                        <ContentControl Margin="{StaticResource ResourceKey=TabItemMargin}" Content="{Binding Path=AboutViewModel}"/>
                    </TabItem>
                    <TabItem Header="{DynamicResource ResourceKey=SettingsTabText}">
                        <ContentControl Margin="{StaticResource ResourceKey=TabItemMargin}" Content="{Binding Path=SettingsViewModel}"/>
                    </TabItem>
                    <TabItem Header="{DynamicResource ResourceKey=LicenseTabText}">
                        <ContentControl Margin="{StaticResource ResourceKey=TabItemMargin}" Content="{Binding Path=LicenseViewModel}"/>
                    </TabItem>
                </TabControl>
            </TabItem>
        </TabControl>

        <StackPanel
            x:Name="watermark"
            Grid.ZIndex="99"
            IsHitTestVisible="False"
            VerticalAlignment="Center"
            TextElement.Foreground="White">
            <StackPanel.Effect>
                <DropShadowEffect/>
            </StackPanel.Effect>
            <StackPanel HorizontalAlignment="Center">
                <Grid Margin="5,0,0,-20" TextElement.FontSize="16" TextElement.FontWeight="Bold">
                    <TextBlock Text="myManga.codeplex.com" HorizontalAlignment="Left" />
                    <TextBlock Text="{Binding Path=AboutViewModel.AssemblyVersion, StringFormat=v{0}}" HorizontalAlignment="Right" />
                </Grid>
                <TextBlock 
                    Text="myManga Beta"
                    FontSize="50"
                    Margin="0,0,0,0"/>
                </StackPanel>
        </StackPanel>
        
        <ContentControl Content="{Binding Path=toastNotification}" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="25,16"/>
    </Grid>
</Window>
